package com.ittest.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ittest.domain.Book;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class IBookServiceTestCase {

    @Autowired
    private IBookservice iBookservice;


    @Test
    void testGetById() {
        System.out.println(iBookservice.getById(1));
    }
    @Test
    void testGetAll() {
        System.out.println(iBookservice.list());
    }
    @Test
    void testsave() {
        Book book = new Book();
        book.setName("java是怎样炼成的");
        book.setType("理论");
        book.setDescription("当一个java诞生的时候，他就有了灵魂");


        System.out.println(iBookservice.save(book));
    }
    @Test
    void testupdate() {
        Book book = new Book();
        book.setId(24);
        book.setName("java是什么");
        book.setType("知识");
        book.setDescription("我们是最好的java");

        System.out.println(iBookservice.updateById(book));
    }
    @Test
    void testdelete() {
        System.out.println(iBookservice.removeById(24));
    }
    @Test
    void testGetPage() {
        IPage<Book> page = new Page<Book>(2,5);
        IPage<Book> ipage = iBookservice.page(page);
        System.out.println(ipage);
    }
    @Test
    void testGetPage2() {

        IPage<Book> page = iBookservice.getPage(1, 2);
        System.out.println(page.getPages());
        System.out.println(page.getRecords());
        System.out.println(page.getTotal());
        System.out.println(page.getSize());
        System.out.println(page.getCurrent());
    }


}
